package testcircuits;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;

import circuits.AndOperator;
import circuits.Operand;

public class TestAndOperator {

	private AndOperator andOperator;
	
	private Operand operand1;
	private Operand operand2;
	private Operand operand3;
	
	@Before
	public void setUp(){
		this.andOperator = new AndOperator();
	}
	
	@Test
	public void allOperandsAreTrueAndOperatorReturnsTrue(){
		this.operand1 = new Operand(true);
		this.operand2 = new Operand(true);
		this.operand3 = new Operand(true);
		
		this.andOperator.addOperand(operand1);
		this.andOperator.addOperand(operand2);
		this.andOperator.addOperand(operand3);
		
		assertTrue(this.andOperator.getResult());
	}
	
	@Test
	public void someOperandsAreFalseAndOperatorReturnsFalse(){
		this.operand1 = new Operand(true);
		this.operand2 = new Operand(true);
		this.operand3 = new Operand(false);
		
		this.andOperator.addOperand(operand1);
		this.andOperator.addOperand(operand2);
		this.andOperator.addOperand(operand3);
		
		assertFalse(this.andOperator.getResult());
	}
	
}
